﻿// ActionScript file
package application.view.components.scroll{
	import caurina.transitions.*;
	
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class ScrollOut extends EventDispatcher{
		public static const COMPLETE:String;
		public static function scrollOut(target:MovieClip):void{
			 var maskShape:Shape=new Shape();
			 maskShape.graphics.lineStyle();
			 maskShape.graphics.beginFill(0);
			 maskShape.graphics.drawRect(0,0,target.width,target.height);
			 maskShape.x=target.x+36.5;
			 maskShape.y=target.y; 
			 
			target.parent.addChild(maskShape);
			
			//位置有问�?
			target.mask=maskShape;
			Tweener.addTween(target,{x:target.x-target.width,time:.5,transition:"easeOutQuart",onComplete:disEvent});
		}
		public static function scrollIn(target:MovieClip):void{
			var maskShape:Shape=new Shape();
			maskShape.graphics.lineStyle();
			maskShape.graphics.beginFill(0);
			maskShape.graphics.drawRect(0,0,target.width,target.height);
			maskShape.x=target.x+35;
			maskShape.y=target.y;
			
			target.parent.addChild(maskShape);
			target.mask=maskShape;
			Tweener.addTween(target,{x:target.x+target.width,time:.5,transition:"easeOutQuart",onComplete:disEvent});
		}
		private function disEvent():void{
			dispatchEvent(new Event(ScrollOut.COMPLETE));
		}
	}
}